package dongshi.daddy.wrapper;

public class CalWasteTimeWapper implements BusinessTopInterface {
    private BusinessTopInterface businessTopInterface;

    // 注意这里必须有一个接收BusinessTopInterface为唯一参数的构造函数，这样才会被识别为Wrapper类
    public CalWasteTimeWapper(BusinessTopInterface businessTopInterfaceIn) {
        this.businessTopInterface = businessTopInterfaceIn;
    }

    @Override
    public void sayHi() {
        System.out.println("*** cal waste time begin***");
        long startTime = System.currentTimeMillis();
        // 调用被包裹的类，这里是RecordInvokeLogWapper
        businessTopInterface.sayHi();
        System.out.println("invoke waste time is: " + (System.currentTimeMillis() - startTime));
    }
}
